package com.liusand.controller;

import com.liusand.common.Result;
import com.liusand.service.SetmealService;
import com.liusand.vo.ClientSetmealVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author :liusha
 * packageName :com.liusand.controller
 * fileName :SetmealController
 * creationTime :2022/12/3 21:18
 */
@RestController
@RequestMapping("setmeal")
public class SetmealController {
    @Autowired
    private SetmealService setmealService;

    @GetMapping("list")
    public Result list(String categoryId, Integer status){
        List<ClientSetmealVo> clientSetmealVoList = setmealService.list(categoryId, status);
        return Result.success(clientSetmealVoList);
    }

    @GetMapping("dish/{id}")
    public Result findSetmealByIdClient(@PathVariable String id){
        if(id == null){
            return Result.error("查询失败");
        }
        ClientSetmealVo clientSetmealVo = setmealService.findSetmealByIdClient(id);
        if(clientSetmealVo == null){
            return Result.error("查询失败");
        }
        return Result.success(clientSetmealVo);
    }
}
